Type.registerNamespace("Telerik.Web");
(function(){var a=Telerik.Web.UI;
a.RatingPrecision=function(){};
a.RatingPrecision.prototype={Item:0,Half:1,Exact:2};
a.RatingPrecision.registerEnum("Telerik.Web.UI.RatingPrecision");
a.RatingSelectionMode=function(){};
a.RatingSelectionMode.prototype={Single:0,Continuous:1};
a.RatingSelectionMode.registerEnum("Telerik.Web.UI.RatingSelectionMode");
a.RadRatingRatingEventArgs=function(b){a.RadRatingRatingEventArgs.initializeBase(this);
this._newValue=b;
};
a.RadRatingRatingEventArgs.prototype={get_newValue:function(){return this._newValue;
}};
a.RadRatingRatingEventArgs.registerClass("Telerik.Web.UI.RadRatingRatingEventArgs",Sys.CancelEventArgs);
a.RadRatingRatedEventArgs=function(b){a.RadRatingRatedEventArgs.initializeBase(this);
this._oldValue=b;
};
a.RadRatingRatedEventArgs.prototype={get_oldValue:function(){return this._oldValue;
}};
a.RadRatingRatedEventArgs.registerClass("Telerik.Web.UI.RadRatingRatedEventArgs",Sys.EventArgs);
a.RadRating=function(b){a.RadRating.initializeBase(this,[b]);
this._itemCount=5;
this._value=0;
this._doubleValue="0";
this._selectionMode=a.RatingSelectionMode.Continuous;
this._precision=a.RatingPrecision.Item;
this._orientation=a.Orientation.Horizontal;
this._isDirectionReversed=false;
this._enableToolTips=true;
this._autoPostBack=false;
this._readOnly=false;
this._enabled=true;
this._uniqueID=null;
this._preInitializeComplete=false;
this._items=null;
this._ulWrapper=null;
this._documentMouseMoveDelegate=null;
};
a.RadRating.prototype={initialize:function(){if(!this._preInitializeComplete){a.RadRating._preInitialize(this.get_id(),this._orientation);
}a.RadRating.callBaseMethod(this,"initialize");
var e=this._ulWrapper=$telerik.getFirstChildByTagName(this.get_element(),"ul",0);
var c=this._items=$telerik.getChildrenByTagName(e,"li");
if(this._isDirectionReversed){var b=[];
for(var d=(c.length-1);
d>=0;
d--){b[b.length]=c[d];
}this._items=b;
}if(!this._readOnly&&this._enabled){$addHandlers(e,{mouseover:this._mouseOver,mouseup:this._mouseUp,mouseout:this._mouseOut},this);
}$addHandler(e,"click",$telerik.cancelRawEvent);
this.raiseEvent("load");
},dispose:function(){this._attachDocumentHandlers(false);
this._createPartElements(false);
this._storeStartCoords(false);
this._spanSize=null;
this._hoveredItem=null;
$clearHandlers(this._ulWrapper);
this._items=null;
this._ulWrapper=null;
a.RadRating.callBaseMethod(this,"dispose");
},repaint:function(){a.RadRating._preInitialize(this.get_id(),this._orientation);
},_getItem:function(c){for(var b=0;
b<3;
b++){if("li"==c.tagName.toLowerCase()){return c;
}c=c.parentNode;
}return null;
},_getItemA:function(c){var b=c.getElementsByTagName("a");
if(b&&b.length>0){return b[0];
}return null;
},_getItemSpan:function(c){var b=c.getElementsByTagName("span");
if(b&&b.length>0){return b[0];
}return null;
},_getItemValue:function(d,b){var c=this._getItemSpan(d);
if(!c){return;
}var e=parseFloat(c.innerHTML);
if(a.RatingPrecision.Item!=this._precision){e-=1;
e+=this._getFraction(d,b);
}if(!isNaN(e)){return e;
}return 0;
},_getFraction:function(d,g){if(!d){return;
}var f=0;
var c=(a.Orientation.Horizontal==this._orientation?"width":"height");
var h=$telerik.getSize(this._getItemA(d))[c];
var e=this._overPartItem;
var b=this._overPartItemComplement;
if(g&&e&&b){var j=$telerik.getSize(e)[c];
var i=$telerik.getSize(b)[c];
f=Math.max(j,i);
if(0==f&&Sys.UI.DomElement.containsCssClass(d,"rrtOver")){return 1;
}}else{f=$telerik.getSize(this._getItemSpan(d))[c];
if(this._isDirectionReversed){f=h-f;
}}return Math.round((f/h)*10)/10;
},_markContinuous:function(b,c){if(this._selectionMode!=a.RatingSelectionMode.Continuous){return;
}var d=this._items;
for(var e=0,g=d.length;
e<g;
e++){var f=d[e];
if(b===f){break;
}if(!Sys.UI.DomElement.containsCssClass(f,c)){Sys.UI.DomElement.addCssClass(f,c);
}}},_clearOverState:function(e){var c=(a.RatingSelectionMode.Continuous==this._selectionMode);
var d=this._items;
var b=e?this._getItemValue(e):null;
for(var g=(d.length-1);
g>=0;
g--){var f=d[g];
if(c&&b!=null&&(b>this._getItemValue(f))){return;
}Sys.UI.DomElement.removeCssClass(f,"rrtOver");
}},_clearSelection:function(e){var d=(a.RatingSelectionMode.Continuous==this._selectionMode);
var f=this._items;
var b=(Math.ceil(this._value)-1);
for(var g=b;
g>=0;
g--){var h=f[g];
if(b==g){this._clearPart(h);
}var c=this._getItemValue(h);
if(e&&((d&&e>c)||(e==c))){return;
}Sys.UI.DomElement.removeCssClass(h,"rrtSelected");
}},_clearPart:function(e,c){var d=this._getItemSpan(e);
if(!d){return;
}var b=c?(c.toString()+"px"):"";
d.style[a.Orientation.Horizontal==this._orientation?"width":"height"]=b;
},_updateHoveredItem:function(l){this._mouseOut(l,true);
var b=this._hoveredItem;
var r=this._overPartItem;
var p=this._overPartItemComplement;
if(!b||!r||!p){return;
}var f=$telerik.getDocumentRelativeCursorPosition(l)[this._locationProperty];
var q=f-this._ulLocation;
q=Math.min(this._maxMousePosition,Math.max(0,q));
q%=this._itemOuterSize;
q-=this._positionOffset;
if(Sys.UI.DomElement.containsCssClass(b,"rrtOver")){Sys.UI.DomElement.removeCssClass(b,"rrtOver");
}var o=this._getOverPartsSize(q,b);
var i=o.partSize;
var c=o.partComplementSize;
var g=this._sizeProperty;
r.style[g]="1px";
p.style[g]="1px";
var m=(a.Orientation.Horizontal==this._orientation);
if(this._isDirectionReversed){var d=this._marginProperty;
var s=this._itemSize;
var j=this._spanSize;
var n=s-i-(m?0:j);
r.style[d]=n.toString()+"px";
var h=s-c-(m?0:(j+n+i));
p.style[d]=h.toString()+"px";
}else{if(!m){r.style.marginTop=(-c).toString()+"px";
}}r.style[g]=i.toString()+"px";
p.style[g]=c.toString()+"px";
if(this._enableToolTips){var k=this._getItemA(b);
k.title=this._getItemValue(b,true);
}},_getOverPartsSize:function(c,d){var b=this._isDirectionReversed;
var i=this._itemSize;
var h=this._itemHalfSize;
var f=this._precision;
var e=(a.RatingPrecision.Half==f);
var k=0;
var j=0;
if(((a.RatingPrecision.Exact==f)&&(c<0||c>=i))||(e&&((!b&&c>h)||(b&&c<=h)))){if(((!b&&c>=0)||(b&&c<i))&&!Sys.UI.DomElement.containsCssClass(d,"rrtOver")){Sys.UI.DomElement.addCssClass(d,"rrtOver");
}}else{var g=this._spanSize;
if(b){if(c>g){j=e?h:(i-c);
if(e&&(g>h)){k=h;
j=(i-g);
}}else{k=e?h:(i-c);
j=i-g;
}}else{if((c>g)||(e&&(g<h))){k=g;
j=e?h:c;
}else{k=e?h:c;
}}}return{partSize:((k<0)?0:k),partComplementSize:((j<0)?0:j)};
},_createPartElements:function(b){var d=this._overPartItem;
var c=this._overPartItemComplement;
if(b){if(!d){d=document.createElement("span");
d.className="rrtPart";
c=document.createElement("span");
c.className="rrtPartComplement";
this._overPartItem=d;
this._overPartItemComplement=c;
}}else{if(d&&c){d.parentNode.removeChild(d);
this._overPartItem=null;
c.parentNode.removeChild(c);
this._overPartItemComplement=null;
}}},_storeStartCoords:function(d){if(d){var b=(a.Orientation.Horizontal==this._orientation);
var g=this._items[0];
var c=this._getItemA(g);
var h=this._ulWrapper;
var f=this._locationProperty=b?"left":"top";
var e=this._sizeProperty=b?"width":"height";
this._marginProperty=b?"marginLeft":"marginTop";
this._ulLocation=$telerik.getLocation(h)[b?"x":"y"]+($telerik.getMarginBox(h)[f]+$telerik.getBorderBox(h)[f]+$telerik.getPaddingBox(h)[f]);
this._itemOuterSize=$telerik.getOuterSize(g)[e];
this._itemSize=$telerik.getSize(c)[e];
this._itemHalfSize=Math.round(this._itemSize/2);
this._positionOffset=$telerik.getMarginBox(c)[f]+$telerik.getBorderBox(c)[f];
this._maxMousePosition=(this._itemOuterSize*this._itemCount)-1;
}else{this._locationProperty=null;
this._sizeProperty=null;
this._marginProperty=null;
this._ulLocation=null;
this._itemOuterSize=null;
this._itemSize=null;
this._itemHalfSize=null;
this._positionOffset=null;
this._maxMousePosition=null;
}},_attachDocumentHandlers:function(b){if(true==b){this._documentMouseMoveDelegate=Function.createDelegate(this,this._updateHoveredItem);
$telerik.addExternalHandler(document,"mousemove",this._documentMouseMoveDelegate);
}else{if(this._documentMouseMoveDelegate){$telerik.removeExternalHandler(document,"mousemove",this._documentMouseMoveDelegate);
this._documentMouseMoveDelegate=null;
}}},_getFractionSize:function(d,e){if(!d&&!e){return 0;
}var g=0;
var c=this._isDirectionReversed;
var h=(a.Orientation.Horizontal==this._orientation?"width":"height");
var j=$telerik.getSize(this._getItemA(d?d:this._items[0]))[h];
var f=this._overPartItem;
var b=this._overPartItemComplement;
if(f&&b){var l=$telerik.getSize(f)[h];
var k=$telerik.getSize(b)[h];
g=(l>k)?l:k;
if(0==g&&Sys.UI.DomElement.containsCssClass(d,"rrtOver")){g=j;
}if(c){g=j-g;
}}else{if(e!=null){var i=e-Math.floor(e);
if(i>0){if(c){i=1-i;
}g=Math.round(j*i);
}else{g=(-1);
}}}if((c&&g==0)||(!c&&g==j)){g=(-1);
}return g;
},_mouseOver:function(d){var c=this._getItem(d.target||d.srcElement);
if(!c){this._hoveredItem=null;
return;
}var b=this._hoveredItem;
if(b&&b===c){return;
}this._clearOverState(c);
this._markContinuous(c,"rrtOver");
if(a.RatingPrecision.Item!=this._precision){this._mouseOverPrecise(c,d);
}else{if(!Sys.UI.DomElement.containsCssClass(c,"rrtOver")){Sys.UI.DomElement.addCssClass(c,"rrtOver");
}}},_mouseOverPrecise:function(k,h){this._createPartElements(true);
this._hoveredItem=k;
var f=(a.Orientation.Horizontal==this._orientation);
var c=(f?"width":"height");
var j=this._getItemSpan(k);
if(j){this._spanSize=$telerik.getSize(j)[c];
}var g=this._overPartItem;
var b=this._overPartItemComplement;
var d=this._isDirectionReversed;
g.style[c]="0px";
b.style[c]="0px";
if(!f&&!d){b.style.marginTop=(-this._spanSize).toString()+"px";
}var i=this._getItemA(k);
i.appendChild(d?g:b);
i.appendChild(d?b:g);
if(!this._itemOuterSize){this._storeStartCoords(true);
}if(!this._documentMouseMoveDelegate){this._attachDocumentHandlers(true);
}this._updateHoveredItem(h);
},_mouseUp:function(h){var f=this._getItem(h.target||h.srcElement);
if(!f){return;
}var m=(a.RatingPrecision.Item!=this._precision);
var l=this._overPartItem;
var n=this._overPartItemComplement;
if(m&&(!l||!this._overPartItemComplement)){return;
}var c=this._value;
var g=this._getItemValue(f,true);
if(c==g){return;
}var i=new a.RadRatingRatingEventArgs(g);
this.raiseEvent("rating",i);
if(i.get_cancel()){return;
}this._clearSelection(g);
this._markContinuous(f,"rrtSelected");
if(!Sys.UI.DomElement.containsCssClass(f,"rrtSelected")){Sys.UI.DomElement.addCssClass(f,"rrtSelected");
}if(m){var b=this._getItemSpan(f);
var k=this._getFractionSize(f,g);
k=(k<0)?"":k.toString()+"px";
var d=(a.Orientation.Horizontal==this._orientation);
var j=d?"width":"height";
l.style[j]="1px";
n.style[j]="1px";
b.style[j]=k;
this._spanSize=$telerik.getSize(b)[j];
if(!d&&!this._isDirectionReversed){k=(k!="")?("-"+k):"";
n.style.marginTop=k;
}this._updateHoveredItem(h);
}this._setValue(g);
this.raiseEvent("rated",new a.RadRatingRatedEventArgs(c));
if(this._autoPostBack){this._raiseServerEvent();
}},_mouseOut:function(d,c){var b=$telerik.isMouseOverElementEx(this._ulWrapper,d);
if(b){if(!c&&a.RatingPrecision.Item!=this._precision){this._hoveredItem=null;
}return $telerik.cancelRawEvent(d);
}this._attachDocumentHandlers(false);
this._createPartElements(false);
this._storeStartCoords(false);
this._spanSize=null;
this._hoveredItem=null;
this._clearOverState();
},_raiseServerEvent:function(){setTimeout(Function.createDelegate(this,function(){__doPostBack(this._uniqueID);
}),0);
},add_load:function(b){this.get_events().addHandler("load",b);
},remove_load:function(b){this.get_events().removeHandler("load",b);
},add_rating:function(b){this.get_events().addHandler("rating",b);
},remove_rating:function(b){this.get_events().removeHandler("rating",b);
},add_rated:function(b){this.get_events().addHandler("rated",b);
},remove_rated:function(b){this.get_events().removeHandler("rated",b);
},get_itemCount:function(){return this._itemCount;
},get_value:function(){return this._value;
},set_value:function(f){var h=this._value;
var e=(this.get_isInitialized()&&(f!=h));
if(e){var d=this._items;
if(f<0){f=0;
}else{if(f>d.length){f=d.length;
}}f=this._fixValuePrecision(f);
var c=new a.RadRatingRatingEventArgs(f);
this.raiseEvent("rating",c);
if(c.get_cancel()){return;
}this._clearSelection(f);
var g=d[Math.ceil(f-1)];
if(g){this._markContinuous(g,"rrtSelected");
if(!Sys.UI.DomElement.containsCssClass(g,"rrtSelected")){Sys.UI.DomElement.addCssClass(g,"rrtSelected");
}if(a.RatingPrecision.Item!=this._precision){var i=this._getFractionSize(g,f);
i=(i<0)?"":i.toString()+"px";
var b=this._getItemSpan(g);
b.style[a.Orientation.Horizontal==this._orientation?"width":"height"]=i;
}}}this._setValue(f);
if(e){this.raiseEvent("rated",new a.RadRatingRatedEventArgs(h));
if(this._autoPostBack){this._raiseServerEvent();
}}},_setValue:function(b){this._value=b;
this._doubleValue=b.toString();
this.updateClientState();
},_fixValuePrecision:function(b){var d=this._precision;
if(d==a.RatingPrecision.Item){Math.round(b);
}else{if(d==a.RatingPrecision.Half){b=Math.round(b*10)/10;
var c=Math.round((10*(b-Math.floor(b))));
if(c!=0&&c!=5){if(c<3){b=Math.floor(b);
}else{if(c<8){b=Math.floor(b)+(1/2);
}else{b=Math.ceil(b);
}}}}else{if(d==a.RatingPrecision.Exact){b=Math.round(b*10)/10;
}}}return b;
},get_selectionMode:function(){return this._selectionMode;
},set_selectionMode:function(b){this._selectionMode=b;
},get_precision:function(){return this._precision;
},set_precision:function(b){this._precision=b;
},get_orientation:function(){return this._orientation;
},set_orientation:function(b){this._orientation=b;
},get_isDirectionReversed:function(){return this._isDirectionReversed;
},set_isDirectionReversed:function(b){this._isDirectionReversed=b;
},get_enableToolTips:function(){return this._enableToolTips;
},set_enableToolTips:function(b){this._enableToolTips=b;
},get_readOnly:function(){return this._readOnly;
},set_readOnly:function(b){if(this.get_isInitialized()&&b!=this._readOnly){this._enableRatingControl(!b);
}this._readOnly=b;
this.updateClientState();
},get_enabled:function(){return this._enabled;
},set_enabled:function(b){if(this.get_isInitialized()&&b!=this._enabled){this._enableRatingControl(b);
}this._enabled=b;
},_enableRatingControl:function(b){var c=this._ulWrapper;
$clearHandlers(c);
this._attachDocumentHandlers(false);
if(b){$addHandlers(c,{mouseover:this._mouseOver,mouseup:this._mouseUp,mouseout:this._mouseOut},this);
}$addHandler(c,"click",$telerik.cancelRawEvent);
},saveClientState:function(){var d=["readOnly"];
var b={value:this._doubleValue};
for(var c=0,e=d.length;
c<e;
c++){var f=d[c];
b[f]=this["get_"+f]();
}return Sys.Serialization.JavaScriptSerializer.serialize(b);
}};
a.RadRating._preInitialize=function(k,l){var f=$get(k);
if(!f||($telerik.getInvisibleParent(f)!=null)){return;
}var e=f.getElementsByTagName("li");
if(e&&e.length>0){var d=e[0];
var n=a.RadRating._getElementBox(d);
var b=a.RadRating._getElementBox($telerik.getChildrenByTagName(f,"ul")[0]);
var j=$telerik.getChildrenByTagName(d,"a")[0];
var m=$telerik.getOuterSize(j);
m.width+=n.horizontal;
m.height+=n.vertical;
var h=e.length;
var c=(0==l);
var g=b.horizontal+(c?(h*m.width):m.width);
var i=b.vertical+(c?m.height:(h*m.height));
if(parseInt(f.style.width)!=g||parseInt(f.style.height)!=i){$telerik.setSize(f,{width:g,height:i});
}}};
a.RadRating._getElementBox=function(d){var c={horizontal:0,vertical:0};
if(d){var e=$telerik.getBorderBox(d);
var f=$telerik.getPaddingBox(d);
var b=$telerik.getMarginBox(d);
c.horizontal=e.horizontal+f.horizontal+b.horizontal;
c.vertical=e.vertical+f.vertical+b.vertical;
}return c;
};
a.RadRating.registerClass("Telerik.Web.UI.RadRating",a.RadWebControl);
})();
